#ifndef NW_CLIENT_PAL_H_
#define NW_CLIENT_PAL_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "dev.h"
#include "nw_client_struct.h"



struct ClientUserGunInfo *pal_get_user_client_gun_data(void);
struct ClientUserBmsInfo *pal_get_user_client_bms_data(void);

void pal_init(void);

uint8 pal_getserverip(uint8 *ip);
uint32 pal_getserverport(void);


uint8 pal_getconnect_sta(struct ClientUserGunInfo * userinfo);
uint8 pal_getac_input_v_overalarm(struct t_pal_alarm *alarm);
uint8 pal_getac_input_v_lowlarm(struct t_pal_alarm *alarm);
uint8 pal_getcurrent_overalarm(struct t_pal_alarm *alarm);
uint8 pal_getoutput_relay_state(struct ClientUserGunInfo * userinfo);
uint8 pal_gettemp_over_pro(struct t_pal_alarm *alarm);
uint8 pal_getshort_circuit_pro(struct t_pal_alarm *alarm);
uint8 pal_getleakage_pro(struct t_pal_alarm *alarm);
uint8 pal_getstopbutton_trigger(struct t_pal_alarm *alarm);

uint16 pal_getwork_state(struct ClientUserGunInfo * userinfo);
uint16 pal_getoutput_voltage(struct ClientUserGunInfo * userinfo);
uint16 pal_getoutput_current(struct ClientUserGunInfo * userinfo);
uint16 pal_getvoltage_A(struct ClientUserGunInfo * userinfo);
uint16 pal_getvoltage_B(struct ClientUserGunInfo * userinfo);
uint16 pal_getvoltage_C(struct ClientUserGunInfo * userinfo);
uint16 pal_getcurrent_A(struct ClientUserGunInfo * userinfo);
uint16 pal_getcurrent_B(struct ClientUserGunInfo * userinfo);
uint16 pal_getcurrenr_C(struct ClientUserGunInfo * userinfo);

uint32 pal_gettotal_actually_power(struct ClientUserGunInfo * userinfo);
uint32 pal_getelecvalue_outside(struct ClientUserGunInfo * userinfo);

uint8  pal_callback_timesync(uint8 *time);//时间同步
uint8  pal_callback_startcharge(uint8 gunno);//启动充电
uint8  pal_callback_stopcharge(uint8 gunno);//停止充电
uint8  pal_callback_set_net_state(uint8_t state);//设置网络
uint8  pal_callback_get_time_cp56(uint8 *time);//拿取当前cp56的时间  数组 7字节的

uint32 pal_save_history_bill(uint8 *trade_num);//把当前记录存储到记录历史记录
uint32 pal_save_current_bill(uint8 *trade_num,uint8 *data,uint32 len);//更新记录
uint8 pal_read_bill(uint8 *buf);//读取充电记录

void print_alarm(struct t_pal_alarm *alarm);
uint8 isexist_alarm(struct t_pal_alarm *alarm,uint8 *alarmcode);
uint8 ishave_alarm(struct t_pal_alarm *alarm);
void add_alarm(struct t_pal_alarm *alarm,uint8 *alarmcode);
void detele_alarm(struct t_pal_alarm *alarm,uint8 *alarmcode);

/*时间相关的*/

void  transtime(cp56time2a *cptime ,const uint8 *time);
uint8 pal_istime(uint8 *time);
uint32 gettotalsec(uint8 *time);

/*********************必选调用区*********************/
extern int32_t nw_send_touch_card_start_charge(uint32_t gunnum, char_t *id, char_t *pwd, uint8_t type, uint32_t value);
extern int32_t nw_send_touch_charge_idle(uint32_t gun_cnt);
extern int32_t nw_send_touch_charge_stoped(uint32_t gun_cnt, const char_t *stop_reason);
extern int32_t nw_send_touch_error_occured(uint32_t gun_cnt, const char_t* err_no);
extern int32_t nw_send_touch_error_recovered(uint32_t gun_cnt, const char_t* err_no);
extern int32_t nw_touch_set_equipment_id(uint8_t* ID_str);
extern int32_t nw_touch_set_mac_addr(uint8_t* mac_str);
extern int32_t nw_charger_state_reup(uint32_t gun_id);

#ifdef __cplusplus
}
#endif

#endif
